package icu.qx.qc.service.impl;

import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import icu.qx.qc.mapper.QcDrawbackMapper;
import icu.qx.qc.domain.QcDrawback;
import icu.qx.qc.service.IQcDrawbackService;

/**
 * 缺陷Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-18
 */
@Service
public class QcDrawbackServiceImpl implements IQcDrawbackService {
    @Autowired
    private QcDrawbackMapper qcDrawbackMapper;

    /**
     * 查询缺陷
     *
     * @param drawbackCode 缺陷主键
     * @return 缺陷
     */
    @Override
    public QcDrawback selectQcDrawbackByDrawbackCode(String drawbackCode) {
        return qcDrawbackMapper.selectQcDrawbackByDrawbackCode(drawbackCode);
    }

    /**
     * 查询缺陷列表
     *
     * @param qcDrawback 缺陷
     * @return 缺陷
     */
    @Override
    public List<QcDrawback> selectQcDrawbackList(QcDrawback qcDrawback) {
        return qcDrawbackMapper.selectQcDrawbackList(qcDrawback);
    }

    /**
     * 新增缺陷
     *
     * @param qcDrawback 缺陷
     * @return 结果
     */
    @Override
    public int insertQcDrawback(QcDrawback qcDrawback) {
        qcDrawback.setCreateBy(SecurityUtils.getUsername());
        qcDrawback.setCreateTime(DateUtils.getNowDate());
        return qcDrawbackMapper.insertQcDrawback(qcDrawback);
    }

    /**
     * 修改缺陷
     *
     * @param qcDrawback 缺陷
     * @return 结果
     */
    @Override
    public int updateQcDrawback(QcDrawback qcDrawback) {
        qcDrawback.setUpdateBy(SecurityUtils.getUsername());
        qcDrawback.setUpdateTime(DateUtils.getNowDate());
        return qcDrawbackMapper.updateQcDrawback(qcDrawback);
    }

    /**
     * 批量删除缺陷
     *
     * @param drawbackCodes 需要删除的缺陷主键
     * @return 结果
     */
    @Override
    public int deleteQcDrawbackByDrawbackCodes(String[] drawbackCodes) {
        return qcDrawbackMapper.deleteQcDrawbackByDrawbackCodes(drawbackCodes);
    }

    /**
     * 删除缺陷信息
     *
     * @param drawbackCode 缺陷主键
     * @return 结果
     */
    @Override
    public int deleteQcDrawbackByDrawbackCode(String drawbackCode) {
        return qcDrawbackMapper.deleteQcDrawbackByDrawbackCode(drawbackCode);
    }
}
